load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("//bazel:prost.bzl", "generated_files_check")

package(default_visibility = ["//rs/nervous_system:default_visibility"])

filegroup(
    name = "protos",
    srcs = glob(["proto/**/*.proto"]),
)

DEPENDENCIES = [
    # Keep sorted.
    "//rs/types/base_types",
    "@crate_index//:candid",
    "@crate_index//:comparable",
    "@crate_index//:prost",
    "@crate_index//:rust_decimal",
    "@crate_index//:serde",
]

MACRO_DEPENDENCIES = [
]

DEV_DEPENDENCIES = [
]

MACRO_DEV_DEPENDENCIES = [
]

ALIASES = {}

LIB_SRCS = glob(
    ["src/**"],
    exclude = ["**/*tests.rs"],
)

rust_library(
    name = "proto",
    srcs = LIB_SRCS,
    aliases = ALIASES,
    crate_name = "ic_nervous_system_proto",
    proc_macro_deps = MACRO_DEPENDENCIES,
    version = "0.0.1",
    deps = DEPENDENCIES,
)

rust_test(
    name = "proto_test",
    srcs = glob(["src/**/*.rs"]),
    aliases = ALIASES,
    proc_macro_deps = MACRO_DEV_DEPENDENCIES + MACRO_DEPENDENCIES,
    version = "0.0.1",
    deps = DEV_DEPENDENCIES + DEPENDENCIES,
)

generated_files_check(
    name = "check_generated_files",
    srcs = ["tests/check_generated_files.rs"],
    data = glob(["src/gen/**/*.rs"]) + [
        ":protos",
        "//rs/types/base_types:protos",
    ],
    manifest_dir = "rs/nervous_system/proto",
    deps = [
        # Keep sorted.
        "//rs/nervous_system/proto/protobuf_generator:lib",
        "//rs/test_utilities/compare_dirs",
        "@crate_index//:tempfile",
    ],
)
